﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using ExtensionAPI;

namespace Xfire_Network {
	public class Xfire_Network : DispatcherObject, INetworkPlugin {
		#region Private IPlugin Vars
		private string _Name = "Xfire Network";
		private string _Description = "Wtyczka dla sieci Xfire.";
		private string _Author = "Maciej Klemarczyk";
		private string _AuthorEmail = "m.klemarczyk@hotmail.com";
		private string _AuthorUrl = "http://www.codeplex.com/site/users/view/mklemarczyk";
		private string _Version = "1.0.0.0";
		private DateTime _PublishDate = new DateTime( );
		#endregion;

		#region Public IPlugin Properties
		public string Name { get { return this._Name; } }
		public string Description { get { return this._Description; } }
		public string Author { get { return this._Author; } }
		public string AuthorEmail { get { return this._AuthorEmail; } }
		public string AuthorUrl { get { return this._AuthorUrl; } }
		public string Version { get { return this._Version; } }
		public DateTime PublishDate { get { return this._PublishDate; } }
		#endregion

		#region Private INetworkPlugin Vars
		private Contacts _Contacts = new Contacts( );
		private Logs _Logs = new Logs( );
		private int _Login;
		private string _Password;
		private string _Server;
		private int _Port;
		private bool _AutoLogin;
		private string _Desc;
		private ConnectionStatus _Status;
		#endregion

		#region Public INetworkPlugin Properties
		public ExtensionAPI.ContactsAPI.IContacts Contacts { get { return this._Contacts; } }
		public List<ILog> Logs { get { return this._Logs; } }
		public string Login { get { return this._Login.ToString( ); } set { this._Login = Convert.ToInt32(value); } }
		public string Password { get { return this._Password; } set { this._Password = value; } }
		public string Server { get { return this._Server; } set { this._Server = value; } }
		public int Port { get { return this._Port; } set { this._Port = value; } }
		public bool AutoLogin { get { return this._AutoLogin; } set { this._AutoLogin = value; } }
		public string Desc { get { return this._Desc; } set { this._Desc = value; } }
		public ConnectionStatus Status { get { return this._Status; } set { this._Status = value; } }
		#endregion

		#region Public INetworkPlugin Methods
		public void LogIn( ) { }
		public void LogOut( ) { }
		public void ChangePassword(string NewPassword) { }
		public void SendMessage(string To, string Text) { }
		public void Register( ) { }
		public void Detele( ) { }
		public void RemaindPassword( ) { }
		public void FindFriends( ) { }
		public void Register(string Login, string Password) { }
		public void Delete(string Login, string Password) { }
		public void RemaindPassword(string Mail) { }
		public void FindFriends(string Text) { }
		public void Dispose( ) { }
		#endregion

		#region Protected Methods to use handling INetworkPlugin Events
		protected void OnStatusChanged(object sender, EventArgs e) {
			if (this.StatusChanged != null) {
				if (!this.Dispatcher.CheckAccess( ))
					this.Dispatcher.Invoke(new EventHandler(this.OnStatusChanged), sender, e);
				else
					this.StatusChanged(this, e);
			}
		}
		protected void OnDescriptionChanged(object sender, EventArgs e) {
			if (this.DescriptionChanged != null) {
				if (!this.Dispatcher.CheckAccess( ))
					this.Dispatcher.Invoke(new EventHandler(this.OnDescriptionChanged), sender, e);
				else
					this.DescriptionChanged(this, e);
			}
		}
		protected void OnPasswordChanged(object sender, EventArgs e) {
			if (this.PasswordChanged != null) {
				if (!this.Dispatcher.CheckAccess( ))
					this.Dispatcher.Invoke(new EventHandler(this.OnPasswordChanged), sender, e);
				else
					this.PasswordChanged(this, e);
			}
		}
		protected void OnRegistered(object sender, EventArgs e) {
			if (this.Registered != null) {
				if (!this.Dispatcher.CheckAccess( ))
					this.Dispatcher.Invoke(new EventHandler(this.OnRegistered), sender, e);
				else
					this.Registered(this, e);
			}
		}
		protected void OnDeleted(object sender, EventArgs e) {
			if (this.Deleted != null) {
				if (!this.Dispatcher.CheckAccess( ))
					this.Dispatcher.Invoke(new EventHandler(this.OnDeleted), sender, e);
				else
					this.Deleted(this, e);
			}
		}
		protected void OnPasswordRemainded(object sender, EventArgs e) {
			if (this.PasswordRemainded != null) {
				if (!this.Dispatcher.CheckAccess( ))
					this.Dispatcher.Invoke(new EventHandler(this.OnPasswordRemainded), sender, e);
				else
					this.PasswordRemainded(this, e);
			}
		}
		protected void OnFriendsFinded(object sender, EventArgs e) {
			if (this.FriendsFinded != null) {
				if (!this.Dispatcher.CheckAccess( ))
					this.Dispatcher.Invoke(new EventHandler(this.OnFriendsFinded), sender, e);
				else
					this.FriendsFinded(this, e);
			}
		}
		protected void OnMessageSended(object sender, EventArgs e) {
			if (this.MessageSended != null) {
				if (!this.Dispatcher.CheckAccess( ))
					this.Dispatcher.Invoke(new EventHandler(this.OnMessageSended), sender, e);
				else
					this.MessageSended(this, e);
			}
		}
		protected void OnMessageRevided(object sender, EventArgs e) {
			if (this.MessageRevided != null) {
				if (!this.Dispatcher.CheckAccess( ))
					this.Dispatcher.Invoke(new EventHandler(this.OnMessageRevided), sender, e);
				else
					this.MessageRevided(this, e);
			}
		}
		#endregion

		#region Public INetworkPlugin Events
		public event EventHandler StatusChanged;
		public event EventHandler DescriptionChanged;
		public event EventHandler PasswordChanged;
		public event EventHandler Registered;
		public event EventHandler Deleted;
		public event EventHandler PasswordRemainded;
		public event EventHandler FriendsFinded;
		public event EventHandler MessageSended;
		public event EventHandler MessageRevided;
		#endregion
	}
}

public class Contacts : ExtensionAPI.ContactsAPI.IContacts {

}
public class Logs : List<ILog> {

}